package com.vdong.common.oauth.common.util;

import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

/**
 * @author llh
 * Created on 2017/11/13.
 */
@ApiModel("请求返回结果")
@Data
public class Result<T> {
    @ApiModelProperty("错误消息")
    private String message;
    @ApiModelProperty("返回数据")
    private T data;
    @ApiModelProperty("是否成功")
    private String serviceCode;

    public static <T> Result<T> success(T data) {
        Result<T> result = new Result<>();
        result.serviceCode = "E000000000";
        result.data = data;
        return result;
    }

    public static Result success() {
        return success(null);
    }

    public static <T> Result<T> fail(String message) {
        Result<T> result = new Result<>();
        result.serviceCode = "E000000001";
        result.message = message;
        return result;
    }

}
